
import axios from "axios"
import { message } from "antd";
export default function ajax(url, data = {}, method = "GET") {
    return new Promise((resolve, reject) => {
        let result;
        if (method === "GET") {
            result = axios.get(url, {
                params: data
            })
        } else if (method === "POST") {
            result = axios.post(url, data)
        }
        result.then(res => {
            resolve(res)
        }).catch(err => {
            message.error(err.message)
        })
    })
}